﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Model;
using University.Workshop.DataAccess;
using System.Data;

namespace University.Workshop.Business
{
    public static class AgendaManager
    {
        public static bool NewAppointment(Appointment appointment)
        {
            return AgendaDataAccess.InsertNewAppointment(appointment);
        }
        public static DataTable LoadDataGridViewHorary(string dateTimeOrange,string ciUser)
        {
            return AgendaDataAccess.LoadDataGridViewHorary(dateTimeOrange, ciUser);
        }
        public static DataTable LoadDataAppointmentsForToday()
        {
            return AgendaDataAccess.LoadDataAppointmentsForToday();
        }
        //public static DataTable LoadDataPatientsNextAppointment(int ciPatient)
        //{
        //    return AgendaDataAccess.LoadDataPatientsNextAppointment(ciPatient);
        //}

        public static bool ModifyAppointment(Appointment appointment,string idAgenda)
        {
            return AgendaDataAccess.ModifyAppointment(appointment,idAgenda);
        }

        public static DataTable LoadAgenda()
        {
            return AgendaDataAccess.LoadAgenda();
        }

        public static bool NewAgenda(string nameAgenda)
        {
            if (AgendaDataAccess.SearchAgenda(nameAgenda).Rows.Count>= 1)
            {
                return false;
            }
            else
            {
                return AgendaDataAccess.NewAgenda(nameAgenda);
            }
        }

        public static bool ModifyAgenda(string newName, string oldName)
        {            
            if (AgendaDataAccess.SearchAgenda(newName).Rows.Count >= 1)
            {
                return false;
            }
            else
            {
                return AgendaDataAccess.ModifyAgenda(newName, oldName);
            }
        }
    }
}
